package com.frinder.astar;

import java.util.List;

/**
 * @author frinder
 * @date 2018/10/13
 * @Description: ${todo}
 */
public class PathNodeList implements Comparable<PathNodeList> {

    private List<Point> points;

    private int length;

    private String name;

    private PathNodeList(Builder builder) {
        points = builder.points;
        name = builder.name;
        length = points.size();
    }

    public List<Point> getPoints() {
        return points;
    }

    @Override
    public String toString() {
        return "PathNodeList{" +
                "name='" + name + '\'' +
                ", length=" + length +
                ", points=" + points +
                '}';
    }

    @Override
    public int compareTo(PathNodeList o) {
        if (null == o) {
            return -1;
        }
        if (length > o.length) {
            // 降序
            return 1;
        } else if (length < o.length) {
            return -1;
        }
        return 0;
    }

    public static final class Builder {
        private List<Point> points;
        private String name;

        public Builder() {
        }

        public Builder points(List<Point> val) {
            points = val;
            return this;
        }

        public Builder name(String val) {
            name = val;
            return this;
        }

        public PathNodeList build() {
            return new PathNodeList(this);
        }
    }
}
